import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    taskName:[],
  },
  getters: {
        // filter过滤
        filterFlase(state){
          var length = state.taskName.filter((item)=>{
            return item.status == false
          })
          return length.length
        }
  },
  mutations: {
    addName(state,payload){
      var obj = {
        id:state.taskName.length+1,
        taskname:payload,
        status:false,
      }
      state.taskName.push(obj)
    },
    modifyStatus(state,payload){
      // find查找
      var fi = state.taskName.find((item)=>{
        return item.id == payload.id
      })
      if( fi ){
        state.fif = fi
        fi.status = !fi.status
      }
    },
    deleteTask(state,payload){
      var arr = state.taskName.filter((item)=>{
        return item.id != payload.id
      })
      state.taskName = arr
    }

  },
  actions: {
  },
  modules: {
  },

})
